package com.rockxin.cat.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.rockxin.cat.R;
import com.rockxin.cat.bean.LendRecordBean;
import com.rockxin.cat.utils.MoneyHandlingUtils;

import java.util.List;

/**
 * <b>类名称：    LendRecordAdapter             <br/>
 * <b>类描述：    出借记录列表适配器                   <br/>
 * <b>创建人：    Lans               <br/>
 * <b>创建时间：  2018/3/2 13:39     <br/>
 * <b>修改人：                        <br/>
 * <b>修改时间：                      <br/>
 * <b>修改备注：                      <br/>
 *
 * @version 1.0.0 <br/>
 */
public class LendRecordAdapter extends BaseQuickAdapter<LendRecordBean, BaseViewHolder> {
    public LendRecordAdapter(@Nullable List<LendRecordBean> data) {
        super(R.layout.fragment_lend_record_item, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, LendRecordBean item) {
        if (item.getRepay_money().equals("出借金额")) {
            helper.setText(R.id.num, item.getNum())
                    .setText(R.id.project, item.getName())
                    .setText(R.id.lendCrash, item.getRepay_money())
                    .setText(R.id.lendDate, item.getRepay_date());
        } else {
            helper.setText(R.id.num, item.getNum())
                    .setText(R.id.project, item.getName())
                    .setText(R.id.lendCrash, MoneyHandlingUtils.formatDouble(Double.parseDouble(item.getRepay_money())))
                    .setText(R.id.lendDate, item.getRepay_date());
        }
    }
}
